package com.PhysicsPhantom.Launcher;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.ImageButton;
import android.widget.ScrollView;
import com.PhysicsPhantom.Launcher.MyLauncherActivity;


public class LauncherActivity extends Activity{

	
    @Override
    public void onCreate(Bundle savedInstanceState) {
   
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
      //scroller
      		final HorizontalScrollView scroller= (HorizontalScrollView) findViewById(R.id.scroller);
        
        scroller.setSmoothScrollingEnabled(true);
        
     
        
        
        //apps
        final ImageButton apps= (ImageButton) findViewById(R.id.apps);
        
        apps.setOnClickListener(new View.OnClickListener() {
        			
        			@Override
        			public void onClick(View v) {
        				Intent intent = new Intent(LauncherActivity.this, MyLauncherActivity.class);
        				startActivity(intent);
        			}
        		});

         
        
        final ImageButton wbrowser= (ImageButton) findViewById(R.id.wbrowser);
        
        wbrowser.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				String url = "http://www.google.com";
				Intent i = new Intent(Intent.ACTION_VIEW);
				i.setData(Uri.parse(url));
				startActivity(i);
			}
		});




        final ImageButton osettings= (ImageButton) findViewById(R.id.osettings);

        osettings.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				startActivity(new Intent(Settings.ACTION_SETTINGS));
			}
		});

        
        
        
//remove from home screen button
        
        //apps
		final ImageButton delapps= (ImageButton) findViewById(R.id.delapps);

		delapps.setOnClickListener(new View.OnClickListener()  {
			
			@Override
			
			public void onClick(View v) {
				apps.setVisibility(View.GONE);
				delapps.setVisibility(View.GONE);
				
			}
		});


		//web browser
		final ImageButton delwbrowser= (ImageButton) findViewById(R.id.delwbrowser);

		delwbrowser.setOnClickListener(new View.OnClickListener()  {
			
			@Override
			
			public void onClick(View v) {
				wbrowser.setVisibility(View.GONE);
				delwbrowser.setVisibility(View.GONE);
				
			}
		});
		
		//web browser
		final ImageButton delosettings= (ImageButton) findViewById(R.id.dellosettings);

		delosettings.setOnClickListener(new View.OnClickListener()  {
			
			@Override
			
			public void onClick(View v) {
				osettings.setVisibility(View.GONE);
				delosettings.setVisibility(View.GONE);
				
			}
		});
		
		//add button
		final ImageButton addshortcut= (ImageButton) findViewById(R.id.addshortcut);

		addshortcut.setOnClickListener(new View.OnClickListener()  {
			
			@Override
			
			public void onClick(View v) {
				startActivity(new Intent("com.PhysicsPhantom.Launcher"));
		
				
			}
		});
		//done button
				final ImageButton done= (ImageButton) findViewById(R.id.done);

				done.setOnClickListener(new View.OnClickListener()  {
					
					@Override
					
					public void onClick(View v) {
						delwbrowser.setVisibility(View.GONE);
						delosettings.setVisibility(View.GONE);
						delapps.setVisibility(View.GONE);
						done.setVisibility(View.GONE);
						addshortcut.setVisibility(View.GONE);
					}
				});
        
		
        











//edit button
		   final ImageButton edit= (ImageButton) findViewById(R.id.edit);
	        
	        edit.setOnClickListener(new View.OnClickListener() {
	        			
	        			@Override
	        			public void onClick(View v) {
	        			if (apps.getVisibility()==View.VISIBLE){
	        			delapps.setVisibility(View.VISIBLE);
	        			}
	        			if (wbrowser.getVisibility()==View.VISIBLE){
	        			delwbrowser.setVisibility(View.VISIBLE);
	        			}
	        			if (osettings.getVisibility()==View.VISIBLE){
	        			delosettings.setVisibility(View.VISIBLE);
	        			}
	        			
	        			done.setVisibility(View.VISIBLE);
	        			addshortcut.setVisibility(View.VISIBLE);
	        			
	        			
	        			
	        			
	        			
	        			}
	        		});





	  








//code to open editor for all delete buttons
		
		
		//apps 
		apps.setOnLongClickListener(new View.OnLongClickListener()  {
			
			@Override
			
			public boolean onLongClick(View v) {
				if (delapps.getVisibility()==View.GONE){
				delapps.setVisibility(View.VISIBLE);
				}
				else{
					delapps.setVisibility(View.GONE);
				}
				
				return true;
				
				
			}
		});
		
		
		//web browser
		wbrowser.setOnLongClickListener(new View.OnLongClickListener()  {
	
	@Override
	
	public boolean onLongClick(View v) {
		if (delwbrowser.getVisibility()==View.GONE){
		delwbrowser.setVisibility(View.VISIBLE);
		}
		else{
			delwbrowser.setVisibility(View.GONE);
		}
		
		return true;
		
		
	}
});
		
		
		//settings
		osettings.setOnLongClickListener(new View.OnLongClickListener()  {
	
	@Override
	
	public boolean onLongClick(View v) {
		if (delosettings.getVisibility()==View.GONE){
		delosettings.setVisibility(View.VISIBLE);
		scroller.fullScroll(ScrollView.FOCUS_RIGHT);
		}
		else{
			delosettings.setVisibility(View.GONE);
		}
		
	
		return true;
		
		
	}
});
 


    }
}